#! /bin/sh

if [ $# -lt 1 ]; then
    echo "Sintaxe: `basename $0` list-arqs"
    exit 10
fi


for full_file_name in "$@"; do

    echo -n "$full_file_name "
    
    # imagem existe?
    if [ ! -f "$full_file_name" ]; then
        echo " nao encontrado!"
        exit 30
    fi

    new_file_name=$PWD/`basename $full_file_name`
    cp -f $full_file_name $new_file_name 2> /dev/null

    # was a frame already added?
    echo "$new_file_name" | grep M_ 2> /dev/null > /dev/null
    if [ $? -eq 1 ]; then
        echo " nao possui moldura!"
    else

        # remove path
        file_name=${new_file_name##*/}  
        
        # remove extension
        file_name=${file_name%.*}

        # write file name
#        convert $new_file_name -gravity NorthWest -annotate 90x90+20+20 $file_name $new_file_name

        convert $new_file_name -gravity NorthWest -font Courier -pointsize 18 -annotate 90x90+50+20 $file_name $new_file_name

        echo " teve seu nome inserido na foto"
    fi 



done
